//
//  UserMap.h
//  Ridding
//
//  Created by zys on 12-3-20.
//  Copyright 2012年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h> 
#import <CoreLocation/CoreLocation.h> 
#import "ASIHTTPRequest.h"
#import "SBJson.h"
#import "MapUtil.h"
#import "UserAnnotation.h"
#import "RequestUtil.h"
#import "UserView.h"
#import "User.h"
#import "StaticInfo.h"
#import "RiddingAppDelegate.h"
#import "UserSettingViewController.h"
#import "MapAnnotation.h"
#import "StartAnnotation.h"
#import "EndAnnotation.h"
#import "InvitationViewController.h"
#import "MobClick.h"
#import "ActivityView.h"

@interface UserMap : UIViewController <CLLocationManagerDelegate,MKAnnotation,MKMapViewDelegate,UIScrollViewDelegate>
{
    MKMapView *mapView;
    RequestUtil *requestUtil;
    StaticInfo *staticInfo;
    UIColor *line_color;
    bool _isShowTeamers;
    bool _isUserTapViewOut;
    bool _isAnimationing;
    
    CGPoint beginPoint;
    
    NSString *riddingId;
    CLLocation *lastLocation;
  
    bool isShowDelete;
    id<MKAnnotation> showingAnnotation;
    ActivityView *loadingView;
   
    NSTimer *sendMyLocationTimer;
    NSTimer *getToDestinationTimer;
    UIImageView *showTeamButton;
    StartAnnotation *startAnnotation;
    EndAnnotation *endAnnotation;

    BOOL _routesInited;
    bool _zooming;
    bool _userInited;
}

@property(nonatomic, retain) IBOutlet MKMapView *mapView; 
@property(nonatomic, retain) IBOutlet UIImageView *route_view;
@property(nonatomic, retain) UIColor *line_color;
@property(nonatomic, retain) NSMutableArray *routes; 
@property(nonatomic, retain) RequestUtil *requestUtil;
@property(nonatomic, strong) NSMutableArray *userArray;
@property(nonatomic, retain) NSString *riddingId;
@property(nonatomic, retain) StaticInfo *staticInfo;
@property(nonatomic, retain) CLLocation *lastLocation;
@property(nonatomic, retain) CLLocationManager *myLocation;

@property(nonatomic, strong) ActivityView *loadingView;
@property(nonatomic, retain) NSTimer *sendMyLocationTimer;
@property(nonatomic, retain) NSTimer *getToDestinationTimer;
@property(nonatomic, retain) id<MKAnnotation> showingAnnotation;
@property(nonatomic) bool isShowDelete;
@property(nonatomic, retain) UIImageView *showTeamButton;

@property(nonatomic, retain) StartAnnotation *startAnnotation;
@property(nonatomic, retain) EndAnnotation *endAnnotation;

@property(nonatomic, retain) IBOutlet UIButton *backBtn;
@property(nonatomic, retain) IBOutlet UILabel *distanceLabel;
@property(nonatomic, retain) IBOutlet UILabel *toDistanceLabel;
@property(nonatomic, strong) IBOutlet UIView *distanceSpeedView;

@property(nonatomic, strong) IBOutlet UIButton *showMemberButton;
@property(nonatomic, retain) IBOutlet UIImageView *membersStatusView;
@property(nonatomic, retain) IBOutlet UIButton *showLocationButton;
@property(nonatomic, retain) IBOutlet UIButton *zoomInButton;
@property(nonatomic, retain) IBOutlet UIButton *zoomOutButton;
@property(nonatomic, retain) IBOutlet UIImageView *userTapView;
@property(nonatomic, retain) IBOutlet UIScrollView *userScrollView;
@property(nonatomic, retain) NSNumber *riddingStatus;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil riddingId:(NSString*)riddingId;

//Button响应方法
-(IBAction)showMemberButtonClicked:(id)sender;
-(IBAction)showLocationButtonClicked:(id)sender;
-(IBAction)zoomInButtonClicked:(id)sender;
-(IBAction)zoomOutButtonClicked:(id)sender;
-(IBAction)backBtnClick:(id)sender;
//Button初始化方法

-(void) addStartAnnotationWithcoordinateX:(double)coorX coordinateY:(double)coorY   
                                     Title:(NSString*)title Subtitle:(NSString*)subtitle;
-(void) addEndAnnotationWithcoordinateX:(double)coorX coordinateY:(double)coorY   
                                     Title:(NSString*)title Subtitle:(NSString*)subtitle;

-(void)initUserScrollView;
-(void)setMapInfo;
-(void)setUsers;
-(void)drawRoutes;
-(double)getSpeed:(CLLocationManager*)location;
-(void)setUserScrollView;
-(void)updateAnnotations:(NSMutableDictionary*)locations;
-(void)removeAllAnnotations;
-(void)membersViewDownToUp:(CGFloat)width;
-(void)setRiddingLocationToDB:(NSMutableDictionary*)map_dic;
-(void)membersViewUpToDown;
-(void)membersViewDownToUp;
-(void)sendMyLocationQuartz;
-(void)showDetails;
-(double)getSpeed;
-(void)removeAllUserView;
@end
